<template>
	<view>
		<uni-fab ref="fab" :popMenu="false" :pattern="pattern" :horizontal="horizontal" :vertical="vertical"
			:direction="direction" @fabClick="fabClick" />

		<view class="flex align-center justify-center padding-xs title">
			<view class="action">
				<text class="text-black text-bold text-xxl">{{ room_name }}</text>
			</view>
			<text :class="['cuIcon-scan text-main-color fr margin-right text-sxl text-theme', cueTheme]"
				@click="onScanTap"></text>
		</view>

		<view class="cu-item flex justify-between bg-white padding margin-top-xs">
			<view class="content padding-left ">
				<text v-if="CurState == '妊娠'" class="text-333 text-xl text-600">入栏天数</text>
				<text v-if="CurState == '哺乳'" class="text-333 text-xl text-600">哺乳天数</text>
				<text v-else="" class="text-333 text-xl text-600">日龄</text>
			</view>
			<view class="action padding-right-sm ">
				<text class="text-black text-bold text-xl">{{ Day }}</text>
			</view>
		</view>

		

		

		<view class="cu-list menu card-menu margin-top-sm margin-bottom-sm">
			<view class="cu-bar solid-bottom">
				<view class="action position">
					<!-- <text class="cuIcon-titles text-main-color"></text> -->
					<text class="text-black text-md bor-bottom text-xxl text-600">饲喂参数</text>
					<text :class="['border-theme border-line',cueTheme]"></text>
				</view>
			</view>
			<view class="grid col-3 padding-sm bg-white solids-bottom">

				<view class="padding-sm" bindtap="onIntoChart" data-curselect="">
					<view class="flex flex-direction align-center text-center shadow border">
						<text class="text-333 margin-left-xxs text-lg padding-bottom-xs">日饲喂量</text>
						<view>
							<text class="text-orange margin-left-xs text-sxl text-bold">{{ MaxFeed }}</text>
							<text class="text-666 margin-left-xs text-xs">kg</text>
						</view>
					</view>
				</view>
				<view class="padding-sm" bindtap="onIntoChart" data-curselect="">
					<view class="flex flex-direction align-center text-center shadow border">
						<text class="text-333 margin-left-xxs text-lg padding-bottom-xs">已下料 </text>
						<view>
							<text class="text-orange margin-left-xs text-sxl text-bold">{{ Feed }}</text>
							<text class="text-666 margin-left-xs text-xs">kg</text>
						</view>
					</view>
				</view>
				<view class="padding-sm" bindtap="onIntoChart" data-curselect="">
					<view class="flex flex-direction align-center text-center shadow border">
						<text class="text-333 margin-left-xxs text-lg padding-bottom-xs">已下水 </text>
						<view>
							<text class="text-blue margin-left-xs text-sxl text-bold">{{ Water }}</text>
							<text class="text-666 margin-left-xs text-xs">L</text>
						</view>
					</view>
				</view>

			</view>
			
			<view class="cu-item flex flex-direction align-start bg-white">
				<view class="content margin-tb">
					<text :class="['cuIcon-titles text-orange text-theme',cueTheme]"></text>
					<text class="text-333 text-xl text-600">饲喂曲线日偏移量</text>
				</view>
				<!-- <view class="flex justify-center padding-bottom" style="width: 100%;">
					<uni-number-box @change="onOffsetChange" :min="offset_min" :max="offset_max" v-model="offset_value"
						:step="offset_step" />
				</view> -->
				<view class="bg-white title flex justify-center align-center">
					<picker class="" style="display: inline-block;border-radius: 10px; width: 100%;background-color: #ebebeb;" @change="bindOffsetPickerChange" @cancel="bindOffsetPickerCancel" :value="offset_idx"
						:range="offset_text_list">
						<text class="text-orange text-xxl text-cut">{{ offset_text_list[offset_idx] }}</text>
						<text class="text-mute text-xl margin-left cuIcon-order"></text>
						<!-- <text :class="[' text-main-color text-theme iconfont Icon-a-lujing14', cueTheme]"></text> -->
					</picker>
				</view>
			</view>
			
			
			
			
			<view class="cu-item ">
				<view class="content">
					<text :class="['cuIcon-titles text-orange text-theme',cueTheme]"></text>
					<text class="text-333 text-xl text-600">状态</text>
				</view>
				<view class="action" @click="onChangeStage">
					<view v-if="Mode==0 && Stage>0" class="btn text-xl bg-orange padding-xs">
						<text class="padding-lr-xs">哺乳</text>
						<text class="iconfont Icon-a-lujing14"></text>
					</view>
					<view v-if="Mode==0 && Stage==0" class="btn text-xl bg-blue padding-xs">
						<text class="padding-lr-xs">妊娠</text>
						<text class="iconfont Icon-a-lujing14"></text>
					</view>
					<view v-if="Mode>0" class="btn text-xl bg-orange padding-xs">
						<text class="padding-lr-xs">育肥</text>
						<text class="iconfont Icon-a-lujing14"></text>
					</view>
				</view>
			</view>
			<view class="cu-item ">
				<view class="content">
					<text :class="['cuIcon-titles text-orange text-theme',cueTheme]"></text>
					<text v-if="AutoRun > 0" class="text-green text-xl text-600"> 自动饲喂已开启</text>
					<text v-if="AutoRun == 0" class="text-red text-xl text-600"> 停止自动饲喂</text>
				</view>
				<view class="action">
					<view class="btn text-xl bg-blue padding-xs" @click="onSwitchAutoRun">
						<text class="padding-lr-xs">{{ AutoRun == 0 ? '开启' : '停止' }}</text>
					</view>
					<!-- <button v-if="AutoRun == 0" class="mini-btn" type="primary" size="mini"
						@click="onSwitchAutoRun">开启</button>
					<button v-if="AutoRun > 0" class="mini-btn" type="warn" size="mini" @click="onSwitchAutoRun">停止</button> -->
				</view>
			</view>
			<view class="cu-item" v-if="HasAlarm">
				<view class="content">
					<text class="cuIcon-warnfill text-red text-xxxl"></text>
					<text class="text-red text-xl">告警</text>
				</view>
				<view class="action">
					<text class="text-red text-bold text-xl">{{ Alarm }}</text>
				</view>
			</view>
			<view class="cu-item arrow">
				<view class="content">
					<text :class="['cuIcon-titles text-orange text-theme',cueTheme]"></text>
					<text class="text-333 text-xl text-600">饲喂曲线</text>
				</view>
				<view class="action" @click="onCurve">
					<text class="iconfont Icon-a-lujing11 text-xl margin-right-sm"></text>
					<text class="text-orange text-xl">查看</text>
				</view>
			</view>
			<view class="cu-item flex flex-direction align-start bg-white">
				<view class="content margin-tb">
					<text :class="['cuIcon-titles text-orange text-theme',cueTheme]"></text>
					<text class="text-333 text-xl text-600">饲喂时间段</text>
				</view>

				<view v-for="(item, idx) in time_list" :key="idx" class="flex padding-xs bg-white justify-between">
					<view class="padding-xs">
						<view class="flex align-center text-center shadow border basis-lg">
							<text class="iconfont Icon-a-lujing13 text-xxxl margin-right-sm"></text>
							<text class="text-333 margin-left-xxs text-xxl text-600"> {{ item.StartT }} - {{ item.EndT
							}}</text>
						</view>
					</view>
					<view class="padding-xs">
						<view class="flex align-center text-center shadow border ">
							<text class="text-orange margin-left-xxs text-xxl text-600">{{ item.OutT }}%</text>
							<!-- <progress :percent="item.OutT" show-info stroke-width="3" /> -->
						</view>
					</view>
				</view>
			</view>
		</view>

		<!-- <view class="cu-list menu card-menu bg-gray margin-top-sm margin-bottom-sm">
			<view class="cu-bar solid-bottom">
				<view class="action">
					<text class="cuIcon-titles text-main-color"></text><text class="text-black text-md">饲喂时间段</text>
				</view>
			</view>

			<view v-for="(item, idx) in time_list" :key="idx" class="grid col-2 padding-xs bg-white">
				<view class="padding-xs">
					<view class="align-center text-center shadow border">
						<text class="cuIcon-time  text-olive "></text>
						<text class="text-grey margin-left-xxs text-md "> {{ item.StartT }} - {{ item.EndT }}</text>
					</view>
				</view>
				<view class="padding-xs">
					<view class="align-center text-center shadow border">
						<text class="text-grey margin-left-xxs text-md ">{{ item.OutT }}%</text>
						<progress :percent="item.OutT" show-info stroke-width="3" />
					</view>
				</view>
			</view>
		</view> -->

		<view class="cu-list menu card-menu margin-top-sm margin-bottom-sm">
			<view class="cu-bar solid-bottom">
				<view class="action position">
					<!-- <text class="cuIcon-titles text-main-color"></text> -->
					<text class="text-black text-md bor-bottom text-xxl text-600">饲喂记录</text>
					<text :class="['border-theme border-line',cueTheme]"></text>
				</view>
			</view>
			<view class="grid col-3 padding-xs bg-white radius">
				<view class="padding-xs ">
					<view class=" align-center text-center shadow border">
						<text class="text-black margin-left-xxs text-xl text-600 text-center">日期</text>
					</view>
				</view>
				<view class="padding-xs">
					<view class=" align-center text-center shadow border">
						<text class="text-black margin-left-xxs text-600 text-xl ">下料量</text>
					</view>
				</view>
				<view class="padding-xs">
					<view class=" align-center text-center shadow border">
						<text class="text-black margin-left-xxs text-600 text-xl ">下水量</text>
					</view>
				</view>



			</view>

			<view v-for="(item, idx) in his_list" :key="idx" class="grid col-3 padding-xs bg-white">
				<view class="padding-xs">
					<view class="align-center text-center shadow border">
						<!-- <text class="cuIcon-title  text-olive "></text> -->
						<text class="text-666 margin-left-xxs text-xl ">{{ item.date }}</text>
					</view>
				</view>
				<view class="padding-xs">
					<view class="align-center text-center shadow border">
						<text class="text-orange margin-left-xxs text-xxl text-600">{{ item.feed }} </text>
						<text class="text-666 margin-left-xxs text-sm "> kg </text>
					</view>
				</view>
				<view class="padding-xs">
					<view class="align-center text-center shadow border">
						<text class="text-blue margin-left-xxs text-xxl text-600">{{ item.water }}</text>
						<text class="text-666 margin-left-xxs text-sm "> L </text>
					</view>
				</view>
			</view>


		</view>

		<view>
			<!-- 提示窗示例 -->
			<uni-popup ref="alertDialog" type="dialog">
				<uni-popup-dialog :type="msgType" cancelText="取消" confirmText="确认" title="注意" content="确认要修改料量?"
					@confirm="onConfirmOffset" @close="onConfirmOffsetCancel"></uni-popup-dialog>
			</uni-popup>
			<uni-popup ref="alertDialog1" type="dialog">
				<uni-popup-dialog :type="msgType" cancelText="取消" confirmText="确认" title="注意" content="确认要切换?"
					@confirm="onConfirmAutoRun" @close="onConfirmAutoRunCancel"></uni-popup-dialog>
			</uni-popup>
			<uni-popup ref="alertDialog2" type="dialog">
				<uni-popup-dialog :type="msgType" cancelText="取消" confirmText="确认" title="注意" content="确认要切换?"
					@confirm="onConfirmStage" @close="onConfirmStageCancel"></uni-popup-dialog>
			</uni-popup>
		</view>

		<view style="height: 10px;"></view>




	</view>
</template>

<script>
import variables from '../../theme/css-variate.js'
import * as api from 'common/api.js';
const moment = require("../../common/moment.min.js");
import {
	API_HEAD
} from '../../common/api';
export default {
	data() {
		return {
			//scrollHeight: 0,
			horizontal: 'right',
			vertical: 'bottom',
			direction: 'horizontal',
			pattern: {
				icon: 'reload',
				color: '#7A7E83',
				backgroundColor: '#e78c1eaa',
				selectedColor: '#e78c1eaa',
				buttonColor: '#e78c1eaa',
				iconColor: '#fff',

			},

			msgType: 'success',

			sn: '',
			bind_addr: '',
			bind_saddr: '',
			bind_m_s: '',
			row: '',
			col: '',
			room_name: '',
			Online: 0,
			Mode: 0,
			Day: '',
			Stage: 0,
			HasAlarm: 0,
			Alarm: '',
			CurState: '',

			AutoRun: 0,

			MaxFeed: 0,
			Feed: 0,
			Water: 0,

			offset_min: -100,
			offset_max: 100,
			offset_step: 0.1,
			offset_value: 0,
			offset_value_backup: 0,
			
			offset_text_list:[],
			offset_idx:0,
			offset_idx_backup:0,
			
			//阶段
			Stage:0,

			para: {},

			time_list: [],
			his_list: [],
		}
	},

	onReady() {
		let themeType = uni.getStorageSync('themeType')
		this.pattern.buttonColor = variables.getThemeType(themeType);

		// 计算scroll-view高度
		/*uni.getSystemInfo({
			success: resu => {
				//console.info("窗口高度:", resu.windowHeight)
				const query = uni.createSelectorQuery()
				query.select('.title').boundingClientRect()
				query.exec(res => {

					console.info("顶部下拉区域:", res[0])
					this.scrollHeight = resu.windowHeight - res[0].height + 'px';
					console.log('剩余高度', this.scrollHeight);
				})
			}
		})*/
	},
	onLoad: function (option) { //option为object类型，会序列化上个页面传递的参数


		if (option.sn) {
			console.log("sn:", option.sn); //打印出上个页面传递的参数。
			this.sn = option.sn
			console.info("sn:", sn)
			var sn_arr = this.sn.split('#')
			if (sn_arr.length == 2) {
				this.bind_saddr = sn_arr[0]
				if (sn_arr[1] == "1") {
					this.bind_m_s = 0
				} else if (sn_arr[1] == "2") {
					this.bind_m_s = 1
				}
			}
		} else {
			console.log("bind_addr:", option.bind_addr);
			console.log("bind_saddr:", option.bind_saddr);
			console.log("bind_m_s:", option.bind_m_s);
			console.log("row:", option.row);
			console.log("col:", option.col);
			this.bind_addr = option.bind_addr
			this.bind_saddr = option.bind_saddr
			this.bind_m_s = option.bind_m_s
			this.row = option.row
			this.col = option.col
		}


		this.loadRoom()
	},
	onNavigationBarButtonTap(e) {
		console.info(e);
		uni.redirectTo({
			url: "/pages/scan/scan"
		})
		//this.loadRoom()
	},
	methods: {
		onScanTap() {
			uni.navigateTo({
				url: "/pages/scan/scan"
			})
		},
		loadRoom() {
			var that = this
			var pda_id = uni.getStorageSync('pda_id');
			uni.showLoading({
				title: '加载中'
			})
			uni.request({
				header: {
					'content-type': 'application/x-www-form-urlencoded'
				},
				url: api.API_HEAD + '/load_room',
				method: 'POST',
				data: {
					"pda_id": pda_id,
					"bind_saddr": that.bind_saddr,
					"bind_m_s": that.bind_m_s,
					"sn": that.sn,
				},
				success: res => {
					//console.info("success");
					console.info(JSON.stringify(res.data));
					if (res.data) {
						//console.info(res.data.data);
						if (res.data.code >= 0) {
							console.info(res.data.data.housename);
							that.room_name = res.data.data.housename + " " + (parseInt(res.data.data
								.room_row) + 1) + "行" + (parseInt(res.data.data.room_col) + 1) + "列"
							that.bind_addr = res.data.data.bind_addr
							that.bind_saddr = res.data.data.bind_saddr
							that.bind_m_s = res.data.data.bind_m_s

							that.getStatus()
							that.loadFeedHis()
						} else {
							uni.showToast({
								title: res.data.msg
							})
						}

					}
				},
				fail: (err) => {
					uni.showToast({
						title: '请求接口失败！'
					})

				},
				//请求结束之后，执行的回调函数（成功或失败都会执行）
				complete() {
					//隐藏loading
					uni.hideLoading()
				}
			});
		},
		getStatus() {
			var that = this
			var pda_id = uni.getStorageSync('pda_id');
			uni.showLoading({
				title: '加载中'
			})
			uni.request({
				header: {
					'content-type': 'application/x-www-form-urlencoded'
				},
				url: 'http://120.78.141.134:8199/api/v1/grow_save_036/slaveStatus',
				method: 'GET',
				data: {
					"addr": that.bind_addr,
					"saddr": that.bind_saddr,
				},
				success: res => {
					//console.info("success");
					//console.info(JSON.stringify(res.data));
					if (res.data) {

						if (res.data.code >= 0) {
							var status = res.data.data
							console.info(status);
							that.Online = 1
							that.Day = status.Day[that.bind_m_s]
							that.Mode = status.Mode
							that.Stage = status.Stage[that.bind_m_s]
							//status.AlarmStr[that.bind_m_s] = "堵料堵水"
							if (status.AlarmStr[that.bind_m_s] != "") {
								that.HasAlarm = 1
								that.Alarm = status.AlarmStr[that.bind_m_s]
							}
							var cur_state = '';
							if (that.Mode > 0) {
								cur_state = '育肥'
							} else {
								cur_state = ''
							}
							if (that.Stage > 0) {
								cur_state += '哺乳'
							} else {
								cur_state += '妊娠'
							}
							that.CurState = cur_state

							that.MaxFeed = parseFloat(parseFloat(status.MaxFeed[that.bind_m_s]).toFixed(
								2));
							that.Feed = parseFloat((parseFloat(status.DayUseFeedAuto[that.bind_m_s]) +
								parseFloat(status.DayUseFeedMan[that.bind_m_s])).toFixed(2));
							that.Water = parseFloat((parseFloat(status.DayUseWaterAuto[that.bind_m_s]) +
								parseFloat(status.DayUseWaterMan[that.bind_m_s])).toFixed(2));

							that.getParam()
						} else {
							uni.showToast({
								icon: 'error',
								title: '饲喂器离线'
							})
						}

					}
				},
				fail: (err) => {
					uni.showToast({
						title: '请求接口失败！'
					})

				},
				//请求结束之后，执行的回调函数（成功或失败都会执行）
				complete() {
					//隐藏loading
					uni.hideLoading()
				}
			})
		},
		getParam() {
			var that = this
			var pda_id = uni.getStorageSync('pda_id');
			uni.showLoading({
				title: '加载中'
			})
			uni.request({
				header: {
					'content-type': 'application/x-www-form-urlencoded'
				},
				url: 'http://120.78.141.134:8199/api/v1/grow_save_036/slaveParams',
				method: 'GET',
				data: {
					"addr": that.bind_addr,
					"saddr": that.bind_saddr,
				},
				success: res => {
					//console.info("success");
					//console.info(JSON.stringify(res.data));
					if (res.data) {

						if (res.data.code >= 0) {
							var param = res.data.data
							that.para = param
							console.info(JSON.stringify(that.para));
							
							that.offset_step = parseFloat(param.AutoOut)
							that.offset_max = parseFloat((5 * that.offset_step).toFixed(1))
							that.offset_min = parseFloat((-5 * that.offset_step).toFixed(1))
							that.offset_value = parseFloat((param.Offset[that.bind_m_s] * that.offset_step)
								.toFixed(1))
							that.offset_value_backup = that.offset_value
							//console.info(that.offset_value)
							
							var _offset_text_list=[];
							for(var i=-5;i<=5;i++){
								_offset_text_list.push(parseFloat((i * that.offset_step).toFixed(1)).toString()+" kg")
								if(param.Offset[that.bind_m_s]==i){
									that.offset_idx = i+5
									that.offset_idx_backup = that.offset_idx
								}
							}
							that.offset_text_list = _offset_text_list
							
							that.AutoRun = param.AutoRun[that.bind_m_s]
							that.Stage = param.Stage[that.bind_m_s]

							that.time_list = []
							var StartT = param.StartT[that.bind_m_s]
							var EndT = param.EndT[that.bind_m_s]
							var OutT = param.OutT[that.bind_m_s]
							for (var i = 0; i < StartT.length; i++) {
								var time = {};
								if (StartT[i] != "00:00" && EndT[i] != "00:00" && OutT[i] > 0) {
									time.StartT = StartT[i]
									time.EndT = EndT[i]
									time.OutT = OutT[i]
									that.time_list.push(time)
								}
							}
						} else {
							uni.showToast({
								icon: 'error',
								title: '饲喂器离线'
							})
						}

					}
				},
				fail: (err) => {
					uni.showToast({
						title: '请求接口失败！'
					})

				},
				//请求结束之后，执行的回调函数（成功或失败都会执行）
				complete() {
					//隐藏loading
					uni.hideLoading()
				}
			})
		},

		setParam() {
			var that = this
			var pda_id = uni.getStorageSync('pda_id');
			uni.showLoading({
				title: '加载中'
			})
			console.info(JSON.stringify(that.para));
			uni.request({
				header: {
					'content-type': 'application/x-www-form-urlencoded'
				},
				url: 'http://120.78.141.134:8199/api/v1/grow_save_036/slaveParams',
				//url: 'http://127.0.0.1:8199/api/v1/grow_save_036/slaveParams',
				method: 'PUT',
				data: {
					"addr": that.bind_addr,
					"saddr": that.bind_saddr,
					"params": JSON.stringify(that.para)
				},
				success: res => {
					//console.info("success");
					//console.info(JSON.stringify(res.data));
					if (res.data) {

						if (res.data.code >= 0) {
							uni.showModal({
								title: "提示",
								content: "设置成功",
								showCancel: false,
								confirmText: "确定"
							})
						} else {
							uni.showToast({
								icon: 'error',
								title: '设置成功失败'
							})
						}

					}
				},
				fail: (err) => {
					uni.showToast({
						title: '请求接口失败！'
					})

				},
				//请求结束之后，执行的回调函数（成功或失败都会执行）
				complete() {
					//隐藏loading
					uni.hideLoading()
				}
			})
		},

		loadFeedHis() {
			var that = this
			var pda_id = uni.getStorageSync('pda_id');
			uni.showLoading({
				title: '加载中'
			})
			uni.request({
				header: {
					'content-type': 'application/x-www-form-urlencoded'
				},
				url: api.API_HEAD + '/load_feed_his',
				method: 'GET',
				data: {
					"pda_id": pda_id,
					"addr": that.bind_addr,
					"saddr": that.bind_saddr,
					"begin": moment().add(-7, 'days').format('YYYY-MM-DD'),
					"end": "",
				},
				success: res => {
					//console.info("success");
					//console.info(JSON.stringify(res.data));
					if (res.data) {

						if (res.data.code >= 0) {
							var his_data = res.data.data
							console.info(his_data);
							that.his_list = []
							for (var i = 0; i < his_data.length; i++) {
								var his = his_data[i]
								var feed = parseFloat(his["day_use_feed_man" + that.bind_m_s.toString()]) +
									parseFloat(his["day_use_feed_auto" + that.bind_m_s.toString()])
								var water = parseFloat(his["day_use_water_man" + that.bind_m_s
									.toString()]) + parseFloat(his["day_use_water_auto" + that.bind_m_s
										.toString()])
								that.his_list.push({
									date: moment(his.his_date).format("YYYY-MM-DD"),
									feed: parseFloat(feed.toFixed(2)),
									water: parseFloat(water.toFixed(2)),
								})
							}

						} else {
							uni.showToast({
								title: res.data.msg
							})
						}

					}
				},
				fail: (err) => {
					uni.showToast({
						title: '请求接口失败！'
					})

				},
				//请求结束之后，执行的回调函数（成功或失败都会执行）
				complete() {
					//隐藏loading
					uni.hideLoading()
				}
			})
		},

		onCurve() {
			// uni.showModal({
			// 	title: "提示",
			// 	content: "功能稍后推出~",
			// 	showCancel: false,
			// 	confirmText: "确定"
			// })
			var that = this
			uni.navigateTo({
				url: "/pages/curve/curve?room_name=" + that.room_name + "&bind_saddr=" + that.bind_saddr +
					"&bind_m_s=" + that.bind_m_s + "&para=" + encodeURIComponent(JSON.stringify(that.para))
			})
		},

		fabClick() {
			console.info("fabClick")
			this.loadRoom()
		},
		bindOffsetPickerCancel(e){
			console.info("onConfirmOffsetCancel")
			console.info("this.offset_value_backup:", this.offset_value_backup)
			//还原
			this.offset_idx = this.offset_idx_backup
		},
		//饲喂偏移修改
		bindOffsetPickerChange(e){
			console.info("bindOffsetPickerChange")
			this.offset_idx = e.detail.value
			//this.para.Offset[this.bind_m_s] = this.offset_idx-5
			//console.info("this.para.Offset:", this.para.Offset[this.bind_m_s])
			this.msgType = "info"
			this.$refs.alertDialog.open()
		},
		onOffsetChange(value) {
			console.info("onOffsetChange", value)
			console.info("this.offset_value:", this.offset_value)
			this.msgType = "info"
			this.$refs.alertDialog.open()
		},
		onConfirmOffset() {
			console.info("onConfirmOffset")
			console.info("this.offset_idx:", this.offset_idx)
			
			var old_offset = this.para.Offset[this.bind_m_s]
			this.para.Offset[this.bind_m_s] = this.offset_idx-5
			var new_offset = this.para.Offset[this.bind_m_s]
			var diff_offset = new_offset - old_offset
			console.info("old_offset",old_offset)
			console.info("new_offset",new_offset)
			console.info("diff_offset",diff_offset)
			var diff_offset_val =parseFloat((parseFloat(this.para.AutoOut).toFixed(1) * diff_offset).toFixed(1))
			console.info("diff_offset_val",diff_offset_val)

			//马上变更日饲喂量
			this.MaxFeed = (parseFloat(this.MaxFeed) + diff_offset_val).toFixed(1)
			//要转换成string
			this.para.Offset[this.bind_m_s] = this.para.Offset[this.bind_m_s].toString()
			this.setParam()
		},
		onConfirmOffsetCancel() {
			console.info("onConfirmOffsetCancel")
			//console.info("this.offset_value_backup:", this.offset_value_backup)
			//还原
			this.offset_idx = this.offset_idx_backup
		},
		onSwitchAutoRun() {
			this.msgType = "info"
			this.$refs.alertDialog1.open()
		},
		onConfirmAutoRun() {

			this.AutoRun = this.AutoRun > 0 ? 0 : 1;
			console.info("this.AutoRun:", this.AutoRun)
			this.para.AutoRun[this.bind_m_s] = this.AutoRun.toString()
			this.setParam()
		},
		onConfirmAutoRunCancel() {
			console.info("this.AutoRun:", this.AutoRun)
		},
		
		onChangeStage(){
			console.info("onChangeStage")
			this.msgType = "info"
			this.$refs.alertDialog2.open()
		},
		onConfirmStage(){
			this.Stage = this.Stage > 0 ? 0 : 1;
			console.info("this.Stage:", this.Stage)
			this.para.Stage[this.bind_m_s] = this.Stage.toString()
			this.setParam()
		},
		onConfirmStageCancel(){
			console.info("this.Stage:", this.Stage)
		}
	}
}
</script>

<style>
page {
	background-color: #F5F5F5;
}

uni-page-body {
	/* background-color: #d8d8d8 !important; */
	min-height: 100% !important;
	height: auto !important;
}

.scroll-block {
	/* height: 300rpx; */
	width: 100%;
	padding: 10rpx;
	/* background-color: #cacaca; */
	white-space: nowrap;
	overflow-x: auto;
	overflow-y: auto;
}

.title {
	font-weight: 700;
	font-size: 26px;
	line-height: 30px;
	text-align: center;
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
	padding-right: 10rpx;
}

.cuIcon-scan {
	position: absolute;
	right: 10px;
}

.btn {
	border-radius: 7px;
}
.flex{
	width: 100%;
}
</style>